package com.xayoudao.uneng.domain;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;


/**
 * 封装用户的bean对象
 * @author junjun
 */
public class User implements Serializable{

	
	private static final long serialVersionUID = 1L;
	private String userid;  //用户ID
	private String username; //用户名
	private String mobile; //手机号

	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	//解板服务器返回的用户的json信息到User对象
	public static User parser(JSONObject jsonObject) {
		// {"data":{"id":"307","username":"ceshi","mobile":"15236584213"},"message":"注册成功","code":0}

		User user = null;
		try {
			user = new User();
			user.setUserid(jsonObject.getString("id"));
			user.setUsername(jsonObject.getString("username"));
			user.setMobile(jsonObject.getString("mobile"));
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return user;
	}

	@Override
	public String toString() {
		return "User [userid=" + userid + ", username=" + username
				+ ", mobile=" + mobile + "]";
	}
	
}
